
#pragma once
#include <opencv2/opencv.hpp>
using namespace cv;

class MedianBackground {
private:
  cv::Mat mMedianBackground;

  // be careful about the memory release
  float ****mHistogram;
  float ***mLessThanMedian;
  float mAgingRate;
  float mCurrentAge;
  float mTotalAges;
  int mValuesPerBin;
  int mNumberOfBins;

  cv::Mat initial_image;

public:
  // init image (roi image)
  MedianBackground(cv::Mat initial_image, float aging_rate,
                   int values_per_bin = 4);
  cv::Mat GetBackgroundImage();
  void UpdateBackground(cv::Mat current_frame);
  float getAgingRate() { return mAgingRate; }

  void reset();
};